#include <windows.h>

BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
    TCHAR className[256];
    GetClassName(hwnd, className, 256);

    if (lstrcmp(className, TEXT("Shell_TrayWnd")) == 0 ||
        lstrcmp(className, TEXT("Shell_SecondaryTrayWnd")) == 0)
    {
        RECT rect;
        GetWindowRect(hwnd, &rect);
        *((RECT*)lParam) = rect;
        return FALSE;
    }

    return TRUE;
}

__declspec(dllexport) void GetTaskbarRect(RECT* rect)
{
    EnumWindows(EnumWindowsProc, (LPARAM)rect);
}

__declspec(dllexport) double WINAPI GetScreenScale()
{
    HDC hdc = GetDC(NULL);
    int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
    int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
    ReleaseDC(NULL, hdc);

    if (dpiX == 96 && dpiY == 96) {
        return 1.0;
    } else if (dpiX == 120 && dpiY == 120) {
        return 1.25;
    } else if (dpiX == 144 && dpiY == 144) {
        return 1.5;
    } else {
        return -1.0;
    }
}
